A compiler is a program that takes one representation of a program as its input and produces a different representation of the same program. Compilers typically transform programs from a high-level, human-readable form into a lower-level, machine-readable form. The input representation may be a text file containing code that complies with the specifications of a particular high-level programming language (e.g., in the C or C++ programming language). The output representation is usually a lower-level translation of the same program (e.g., machine or assembly code). Such lower-level representation is usually read by hardware or software, and rarely by people.
During the translation process, compilers usually go through numerous improvement or optimization steps that take advantage of the compiler's “understanding” of the program and employ various techniques to improve the code's efficiency. In an example, during translation, compilers conduct a process of improving the generated assembly code to enhance different characteristics such as performance or code size. Compilers typically perform the translation and optimization at a function scope for a given file. For example, a compiler may read and analyze each function in the high-level source code and then translate the function into assembly code. In this way, the compiler may optimize the code it generates within a function.